<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cen {
         text-align: center
        }
        </style>
</head>
<body>
    <div class="cen">
        <input type="text">
        <button id='test'>免费获取验证码</button>
        </div>
        <script>
           var waitTime = 60;
            document.getElementById("test").onclick = function() {
                time(this);
            }
            function time(ele) {
                if (waitTime == 0) {
                    ele.disabled=false;
                    ele.innerHTML = "免费获取验证码";
                    waitTime = 60;// 恢复计时
                } else {
                    ele.disabled=true;
                    ele.innerHTML = waitTime + "秒后可以重新发送";
                    waitTime--;
                    setTimeout(function() {
                        time(ele)// 关键处-定时循环调用
                    }, 1000)
                }
            }
            //520
        </script>
        
</body>
</html>